import http from "@/config/request";

/** 发表评论 */
export const addComment = (data) => {
  return new Promise((resolve, reject) => {
    http.post("/api/comment/add", data).then((res) => {
      resolve(res);
    });
  });
};

/** 回复评论 */
export const applyComment = (data) => {
  return new Promise((resolve, reject) => {
    http.post("/api/comment/apply", data).then((res) => {
      resolve(res);
    });
  });
};

/** 删除自己的评论 */
export const deleteComment = (id, parent_id = 0) => {
  return new Promise((resolve, reject) => {
    http.delete(`/api/comment/delete/${id}/${parent_id}`, {}).then((res) => {
      resolve(res);
    });
  });
};

/** 获取父级评论 */
export const frontGetParentComment = (data) => {
  return {
    code: 0,
    message: "分页查找评论成功",
    result: {
      current: 1,
      total: 16,
      size: 5,
      list: [{
        content: "推荐使用宝塔哦",
        createdAt: "2023-05-21 16:10:11",
        for_id: 6,
        form_name: "小张",
        from_avatar: "/blog-images/iBvceOjUQOux",
        from_id: 1,
        from_name: "M",
        id: 81,
        ip: "113.109.196.80",
        ipAddress: "广东",
        is_like: false,
        parent_id: null,
        thumbs_up: 14,
        to_avatar: null,
        to_id: null,
        to_name: null,
        type: 1,
        updatedAt: "2024-10-19 22:12:03"
      }]
    }
  }
};

/** 获取子级评论 */
export const frontGetChildrenComment = (data) => {
  return new Promise((resolve, reject) => {
    http.post("/api/comment/frontGetChildrenComment", data).then((res) => {
      resolve(res);
    });
  });
};

// 获取评论总条数
export const frontGetCommentTotal = (data) => {
  return {
    code: 0,
    message: "获取评论总条数成功",
    result: 29
  }
};
